package com.kgw.gatewaybluetooth;

import android.app.Application;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;

import com.classic.core.utils.DeviceUtil;
import com.classic.okhttp.gateway.http.ActionHelp;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;


/**
 * Created by Administrator on 2016/4/18.
 */
public class GbApplication extends Application {


    @Override
    public void onCreate() {
        super.onCreate();
        ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this));
//        initImageLoader(this, null);
        GbCache.setContext(this);
        ActionHelp.init(String.valueOf(DeviceUtil.getInstance(this)), "", false);//true:商用  false:商测

    }

    /**
     * 初始化一个默认配置
     */
    public static void initImageLoader(Context context, DisplayImageOptions options) {
        System.out.println("ImageUtil --> init normal ImageLoader config");
//		File file = new File(IMAGE_CACHE_DIR);
//		if(!file.exists()) file.mkdirs();
        ImageLoaderConfiguration config = null;
        try {
            config = new ImageLoaderConfiguration.Builder(context).threadPriority(Thread.NORM_PRIORITY - 2)
                    .denyCacheImageMultipleSizesInMemory().tasksProcessingOrder(QueueProcessingType.LIFO).threadPoolSize(5)
//                    .diskCache(new LruDiscCache(SDcardUtils.getImagePath(), new Md5FileNameGenerator(), 0))
                    .memoryCacheSizePercentage(60).writeDebugLogs().build();
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (config != null) {
            ImageLoader.getInstance().init(config);
        }
    }
}
